package com.flying.utils.lang;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class StringUtil {
    public static int extractFirstInt(String source) {
        String value = extractFirstString(source, "\\d+");
        return value != null ? Integer.valueOf(value) : -1;
    }

    public static String extractFirstString(String source, String regex) {
        Matcher m = Pattern.compile(regex).matcher(source);
        if (m.find()) return m.group();
        return null;
    }
}